Optimal. Leaf size=274 \[ -\frac {a^2 (A b-a B) \sin (c+d x)}{3 b^2 d \left (a^2-b^2\right ) (a+b \cos (c+d x))^3}+\frac {\left (a^3 A-3 a^2 b B+4 a A b^2-2 b^3 B\right ) \tan ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{d (a-b)^{7/2} (a+b)^{7/2}}+\frac {a \left (-4 a^3 B+a^2 A b+9 a b^2 B-6 A b^3\right ) \sin (c+d x)}{6 b^2 d \left (a^2-b^2\right )^2 (a+b \cos (c+d x))^2}+\frac {\left (2 a^5 B+a^4 A b-5 a^3 b^2 B-10 a^2 A b^3+18 a b^4 B-6 A b^5\right ) \sin (c+d x)}{6 b^2 d \left (a^2-b^2\right )^3 (a+b \cos (c+d x))} \]
[Out]
________________________________________________________________________________________
Rubi [A] time = 0.64, antiderivative size = 274, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 6, integrand size = 31, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.194, Rules used = {2988, 3021, 2754, 12, 2659, 205} \[ \frac {\left (a^3 A-3 a^2 b B+4 a A b^2-2 b^3 B\right ) \tan ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{d (a-b)^{7/2} (a+b)^{7/2}}-\frac {a^2 (A b-a B) \sin (c+d x)}{3 b^2 d \left (a^2-b^2\right ) (a+b \cos (c+d x))^3}+\frac {a \left (a^2 A b-4 a^3 B+9 a b^2 B-6 A b^3\right ) \sin (c+d x)}{6 b^2 d \left (a^2-b^2\right )^2 (a+b \cos (c+d x))^2}+\frac {\left (-10 a^2 A b^3+a^4 A b-5 a^3 b^2 B+2 a^5 B+18 a b^4 B-6 A b^5\right ) \sin (c+d x)}{6 b^2 d \left (a^2-b^2\right )^3 (a+b \cos (c+d x))} \]
Antiderivative was successfully verified.
[In]
[Out]
Rule 12
Rule 205
Rule 2659
Rule 2754
Rule 2988
Rule 3021
Rubi steps
\begin {align*} \int \frac {\cos ^2(c+d x) (A+B \cos (c+d x))}{(a+b \cos (c+d x))^4} \, dx &=-\frac {a^2 (A b-a B) \sin (c+d x)}{3 b^2 \left (a^2-b^2\right ) d (a+b \cos (c+d x))^3}+\frac {\int \frac {3 a b (A b-a B)+\left (a^2-3 b^2\right ) (A b-a B) \cos (c+d x)+3 b \left (a^2-b^2\right ) B \cos ^2(c+d x)}{(a+b \cos (c+d x))^3} \, dx}{3 b^2 \left (a^2-b^2\right )}\\ &=-\frac {a^2 (A b-a B) \sin (c+d x)}{3 b^2 \left (a^2-b^2\right ) d (a+b \cos (c+d x))^3}+\frac {a \left (a^2 A b-6 A b^3-4 a^3 B+9 a b^2 B\right ) \sin (c+d x)}{6 b^2 \left (a^2-b^2\right )^2 d (a+b \cos (c+d x))^2}-\frac {\int \frac {-2 b^2 \left (2 a^2 A b+3 A b^3+a^3 B-6 a b^2 B\right )-b \left (a^3 A b-6 a A b^3+2 a^4 B-3 a^2 b^2 B+6 b^4 B\right ) \cos (c+d x)}{(a+b \cos (c+d x))^2} \, dx}{6 b^3 \left (a^2-b^2\right )^2}\\ &=-\frac {a^2 (A b-a B) \sin (c+d x)}{3 b^2 \left (a^2-b^2\right ) d (a+b \cos (c+d x))^3}+\frac {a \left (a^2 A b-6 A b^3-4 a^3 B+9 a b^2 B\right ) \sin (c+d x)}{6 b^2 \left (a^2-b^2\right )^2 d (a+b \cos (c+d x))^2}+\frac {\left (a^4 A b-10 a^2 A b^3-6 A b^5+2 a^5 B-5 a^3 b^2 B+18 a b^4 B\right ) \sin (c+d x)}{6 b^2 \left (a^2-b^2\right )^3 d (a+b \cos (c+d x))}+\frac {\int \frac {3 b^3 \left (a^3 A+4 a A b^2-3 a^2 b B-2 b^3 B\right )}{a+b \cos (c+d x)} \, dx}{6 b^3 \left (a^2-b^2\right )^3}\\ &=-\frac {a^2 (A b-a B) \sin (c+d x)}{3 b^2 \left (a^2-b^2\right ) d (a+b \cos (c+d x))^3}+\frac {a \left (a^2 A b-6 A b^3-4 a^3 B+9 a b^2 B\right ) \sin (c+d x)}{6 b^2 \left (a^2-b^2\right )^2 d (a+b \cos (c+d x))^2}+\frac {\left (a^4 A b-10 a^2 A b^3-6 A b^5+2 a^5 B-5 a^3 b^2 B+18 a b^4 B\right ) \sin (c+d x)}{6 b^2 \left (a^2-b^2\right )^3 d (a+b \cos (c+d x))}+\frac {\left (a^3 A+4 a A b^2-3 a^2 b B-2 b^3 B\right ) \int \frac {1}{a+b \cos (c+d x)} \, dx}{2 \left (a^2-b^2\right )^3}\\ &=-\frac {a^2 (A b-a B) \sin (c+d x)}{3 b^2 \left (a^2-b^2\right ) d (a+b \cos (c+d x))^3}+\frac {a \left (a^2 A b-6 A b^3-4 a^3 B+9 a b^2 B\right ) \sin (c+d x)}{6 b^2 \left (a^2-b^2\right )^2 d (a+b \cos (c+d x))^2}+\frac {\left (a^4 A b-10 a^2 A b^3-6 A b^5+2 a^5 B-5 a^3 b^2 B+18 a b^4 B\right ) \sin (c+d x)}{6 b^2 \left (a^2-b^2\right )^3 d (a+b \cos (c+d x))}+\frac {\left (a^3 A+4 a A b^2-3 a^2 b B-2 b^3 B\right ) \operatorname {Subst}\left (\int \frac {1}{a+b+(a-b) x^2} \, dx,x,\tan \left (\frac {1}{2} (c+d x)\right )\right )}{\left (a^2-b^2\right )^3 d}\\ &=\frac {\left (a^3 A+4 a A b^2-3 a^2 b B-2 b^3 B\right ) \tan ^{-1}\left (\frac {\sqrt {a-b} \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {a+b}}\right )}{(a-b)^{7/2} (a+b)^{7/2} d}-\frac {a^2 (A b-a B) \sin (c+d x)}{3 b^2 \left (a^2-b^2\right ) d (a+b \cos (c+d x))^3}+\frac {a \left (a^2 A b-6 A b^3-4 a^3 B+9 a b^2 B\right ) \sin (c+d x)}{6 b^2 \left (a^2-b^2\right )^2 d (a+b \cos (c+d x))^2}+\frac {\left (a^4 A b-10 a^2 A b^3-6 A b^5+2 a^5 B-5 a^3 b^2 B+18 a b^4 B\right ) \sin (c+d x)}{6 b^2 \left (a^2-b^2\right )^3 d (a+b \cos (c+d x))}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A] time = 1.32, size = 251, normalized size = 0.92 \[ \frac {\frac {2 \sin (c+d x) \left (10 a^5 B-25 a^4 A b+17 a^3 b^2 B-14 a^2 A b^3+6 a \left (a^4 A+a^3 b B-9 a^2 A b^2+9 a b^3 B-2 A b^4\right ) \cos (c+d x)+\left (2 a^5 B+a^4 A b-5 a^3 b^2 B-10 a^2 A b^3+18 a b^4 B-6 A b^5\right ) \cos (2 (c+d x))+18 a b^4 B-6 A b^5\right )}{(a+b \cos (c+d x))^3}-\frac {24 \left (a^3 A-3 a^2 b B+4 a A b^2-2 b^3 B\right ) \tanh ^{-1}\left (\frac {(a-b) \tan \left (\frac {1}{2} (c+d x)\right )}{\sqrt {b^2-a^2}}\right )}{\sqrt {b^2-a^2}}}{24 d \left (a^2-b^2\right )^3} \]
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
fricas [B] time = 0.87, size = 1220, normalized size = 4.45 \[ \text {result too large to display} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
giac [B] time = 1.03, size = 689, normalized size = 2.51 \[ -\frac {\frac {3 \, {\left (A a^{3} - 3 \, B a^{2} b + 4 \, A a b^{2} - 2 \, B b^{3}\right )} {\left (\pi \left \lfloor \frac {d x + c}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (-2 \, a + 2 \, b\right ) + \arctan \left (-\frac {a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\sqrt {a^{2} - b^{2}}}\right )\right )}}{{\left (a^{6} - 3 \, a^{4} b^{2} + 3 \, a^{2} b^{4} - b^{6}\right )} \sqrt {a^{2} - b^{2}}} + \frac {3 \, A a^{5} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 6 \, B a^{5} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 12 \, A a^{4} b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 3 \, B a^{4} b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 27 \, A a^{3} b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 6 \, B a^{3} b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 12 \, A a^{2} b^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 27 \, B a^{2} b^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 6 \, A a b^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 18 \, B a b^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 6 \, A b^{5} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 4 \, B a^{5} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 28 \, A a^{4} b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 32 \, B a^{3} b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 16 \, A a^{2} b^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 36 \, B a b^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 12 \, A b^{5} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 3 \, A a^{5} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 6 \, B a^{5} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 12 \, A a^{4} b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 3 \, B a^{4} b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 27 \, A a^{3} b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 6 \, B a^{3} b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 12 \, A a^{2} b^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 27 \, B a^{2} b^{3} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 6 \, A a b^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 18 \, B a b^{4} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 6 \, A b^{5} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{{\left (a^{6} - 3 \, a^{4} b^{2} + 3 \, a^{2} b^{4} - b^{6}\right )} {\left (a \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + a + b\right )}^{3}}}{3 \, d} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
maple [B] time = 0.08, size = 1726, normalized size = 6.30 \[ \text {result too large to display} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
maxima [F(-2)] time = 0.00, size = 0, normalized size = 0.00 \[ \text {Exception raised: ValueError} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
mupad [B] time = 4.15, size = 440, normalized size = 1.61 \[ \frac {\mathrm {atan}\left (\frac {\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\left (2\,a-2\,b\right )\,\left (a^3-3\,a^2\,b+3\,a\,b^2-b^3\right )}{2\,\sqrt {a+b}\,{\left (a-b\right )}^{7/2}}\right )\,\left (A\,a^3-3\,B\,a^2\,b+4\,A\,a\,b^2-2\,B\,b^3\right )}{d\,{\left (a+b\right )}^{7/2}\,{\left (a-b\right )}^{7/2}}-\frac {\frac {4\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3\,\left (-B\,a^3+7\,A\,a^2\,b-9\,B\,a\,b^2+3\,A\,b^3\right )}{3\,{\left (a+b\right )}^2\,\left (a^2-2\,a\,b+b^2\right )}+\frac {{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^5\,\left (A\,a^3+2\,A\,b^3-2\,B\,a^3+2\,A\,a\,b^2+6\,A\,a^2\,b-6\,B\,a\,b^2-3\,B\,a^2\,b\right )}{{\left (a+b\right )}^3\,\left (a-b\right )}-\frac {\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\left (A\,a^3-2\,A\,b^3+2\,B\,a^3+2\,A\,a\,b^2-6\,A\,a^2\,b+6\,B\,a\,b^2-3\,B\,a^2\,b\right )}{\left (a+b\right )\,\left (a^3-3\,a^2\,b+3\,a\,b^2-b^3\right )}}{d\,\left (3\,a\,b^2-{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4\,\left (-3\,a^3+3\,a^2\,b+3\,a\,b^2-3\,b^3\right )-{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2\,\left (-3\,a^3-3\,a^2\,b+3\,a\,b^2+3\,b^3\right )+3\,a^2\,b+a^3+b^3+{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^6\,\left (a^3-3\,a^2\,b+3\,a\,b^2-b^3\right )\right )} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
sympy [F(-1)] time = 0.00, size = 0, normalized size = 0.00 \[ \text {Timed out} \]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________